package controller;

import java.util.List;

import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumnModel;

import model.Zimmer;

public class RoomsTableModel extends AbstractTableModel{

	private TableColumnModel tableColumnModel;
	public final String[] HeaderNames = { "Name", "Maximum Persons" };
	private List<Zimmer> rooms;
	
	public RoomsTableModel(List<Zimmer> rooms){
		this.rooms = rooms;
	}
	
	@Override
	public String getColumnName(int column) {
		return HeaderNames[column];
	};
	
	
	
	@Override
	public int getRowCount()
	{
		return rooms.size();
	}

	@Override
	public int getColumnCount()
	{
		return HeaderNames.length;
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex)
	{
		Zimmer z =  rooms.get(rowIndex);
		Object value = "Error";
		switch(columnIndex){
			case 0:
				value = z.getName();
				break;
			case 1:
				value = z.getMaxBelegung();
				break;		
		}
		
		return value;
	}

	public List<Zimmer> getRooms()
	{
		return rooms;
	}
}


